package collection;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;

public class CollectionToArray {
    public static void main(String[] args) {
        Collection<String> c=new ArrayList<>();
        c.add("1");
        c.add("2");
        c.add("3");
        c.add("4");
        c.add("5");
        System.out.println("我是集合"+c);
        String[] str = c.toArray(new String[c.size()]);
        String[] str2 = c.toArray(new String[8]);
        String[] str3 = c.toArray(new String[4]);

        System.out.println("集合转换成String数组"+Arrays.toString(str));
        System.out.println(Arrays.toString(str2));
        System.out.println(Arrays.toString(str3));
        List<String> strings = Arrays.asList(str3);
        System.out.println(strings);


    }
}








